package cn.aloxc.tianya.reader;

import java.util.HashMap;
import java.util.Map;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Activity_test_list extends Activity{
	Button simple_button = null;
	Button array_button = null;
	Button cursor_button = null;
	Button my_button = null;
	Button rss_button = null;
	Button grid_button = null;
	OnClickListener simple_listener = null;
	OnClickListener array_listener = null;
	OnClickListener cursor_listener = null;
	OnClickListener my_listener = null;
	OnClickListener rss_listener = null;
	OnClickListener grid_listener = null;
	Map<String, String> data = null;
	public void onCreate(Bundle savedInstanceState){
		setData();
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_test_list);
        Bundle data = this.getIntent().getExtras();
        setTitle(data.getString("testItem"));
        
        simple_listener = new OnClickListener(){
			public void onClick(View v) {
				Intent intent = new Intent(Activity_test_list.this,Activity_test_list_simple.class);
				Bundle data = new Bundle();
				String text = (String)((Button)v).getText();				
				data.putString("testItem", text);
				intent.putExtras(data);
				startActivity(intent);
			}
        };
        array_listener = new OnClickListener(){
			public void onClick(View v) {
				Intent intent = new Intent(Activity_test_list.this,Activity_test_list_array.class);
				Bundle data = new Bundle();
				String text = (String)((Button)v).getText();				
				data.putString("testItem", text);
				intent.putExtras(data);
				startActivity(intent);
			}
        };
        cursor_listener = new OnClickListener(){
			public void onClick(View v) {
				Intent intent = new Intent(Activity_test_list.this,Activity_test_list_cursor.class);
				Bundle data = new Bundle();
				String text = (String)((Button)v).getText();				
				data.putString("testItem", text);
				intent.putExtras(data);
				startActivity(intent);
			}
        };
        my_listener = new OnClickListener(){
			public void onClick(View v) {
				Intent intent = new Intent(Activity_test_list.this,Activity_test_list_my.class);
				Bundle data = new Bundle();
				String text = (String)((Button)v).getText();				
				data.putString("testItem", text);
				intent.putExtras(data);
				startActivity(intent);
			}
        };
        rss_listener = new OnClickListener(){
			public void onClick(View v) {
				Intent intent = new Intent(Activity_test_list.this,Activity_test_xmlPull.class);
				Bundle data = new Bundle();
				String text = (String)((Button)v).getText();				
				data.putString("testItem", text);
				intent.putExtras(data);
				startActivity(intent);
			}
        };
        grid_listener = new OnClickListener(){
			public void onClick(View v) {
				Intent intent = new Intent(Activity_test_list.this,Activity_test_list_gridview.class);
				Bundle data = new Bundle();
				String text = (String)((Button)v).getText();				
				data.putString("testItem", text);
				intent.putExtras(data);
				startActivity(intent);
			}
        };
    	simple_button = (Button)findViewById(R.id.test_list_simple);
        array_button = (Button)findViewById(R.id.test_list_array);
    	cursor_button = (Button)findViewById(R.id.test_list_cursor);
    	my_button = (Button)findViewById(R.id.test_list_myAdapter);
    	rss_button = (Button)findViewById(R.id.test_list_simple_rss);
    	grid_button = (Button)findViewById(R.id.test_list_gridview);
    	
    	simple_button.setOnClickListener(simple_listener);
    	array_button.setOnClickListener(array_listener);
    	cursor_button.setOnClickListener(cursor_listener);
    	my_button.setOnClickListener(my_listener);
    	rss_button.setOnClickListener(rss_listener);
    	grid_button.setOnClickListener(grid_listener);
	}
	private void setData(){
		data = new HashMap<String, String>();
		data.put("天涯社区", "http://www.tianya.cn");
		data.put("海南在线", "http://www.hainan.net");
		data.put("人才在线", "http://job.hainan.net");
	}
}
